<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8">
		<title>注册</title>
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/basic.css" />
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/Home/reg.css" />
		<script type="text/javascript" src="__PUBLIC__/Js/jquery.js"></script>
		<script>
		var check={'username':false,'password':false};
  		
  		$(function(){
  			check.username=false;
  			$(':input[name=username]').blur(function(){
  				var username=$(this).val();
  				if(username==""||username==null){
  					$('#usermsg').html('不能为空');
  					return;
  				}else{
  					/*	var reg=/^\w{4,20}/;
                   		if(!reg.test(username)){
                   			$('#usermsg').html('用户名为4-20个字符');
                   			return;
                   		}else{
                        	//check.username=true;
                      */
                        	$('#usermsg').html('');
                      		$.get('__URL__/checkName',{'username':username},function(data){
  									
			  					if(data=='允许'){
			  						$('#usermsg').html('用户名可以使用');
			  						check.username=true;
			  					}else{
			  						$('#usermsg').html('该用户名已经注册，请更换');
			  					}
  							});
                       // }
  				}
  				
  			});
  		});
  		
  		$(function(){
  			check.password=false;
  			$(':input[name=password]').blur(function(){
                   var pwd=$(this).val(); 
                   if(pwd==""||pwd==null){
                        $('#passmsg').html('不能为空');
                   }else{
                   		var reg=/^\w{6,20}/;
                   		if(!reg.test(pwd)){
                   			$('#passmsg').html('密码为6-20个数字或字母');
                   		}else{
                        	check.password=true;
                        	$('#passmsg').html('');
                        }
                   }
                }).focus(function(){$('#passmsg').html('');});
  		});
  	//提交表单
  	$(function(){
		$('img.register').click(function(){
			if(check.username==true && check.password==true){
				alert(100);
				$('form[name="myForm"]').submit();
			}else{
				return false;
			}
		});
  	});
			/*
			$(function(){
				var error=new Array();
				$('input[name="username"]').blur(function(){
					var username=$(this).val();
					$.get('__URL__/checkName',{'username':username},function(data){
						if(data=='不允许'){
							error['username']=1;
							$('input[name="username"]').after('<p id="umessage" style="color:red">该用户名已经注册</p>');
						}else{
							error['username']=0;
							$('#umessage').remove();
						}
					});
				}); 

				//提交表单
				$('img.register').click(function(){
					if(error['username']==1){
						return false;
					}else{
						$('form[name="myForm"]').submit();
					}
				});
			});   */
		</script>
	</head>
	<body>
		<form action='__URL__/doReg' method='post' name='myForm'>
			用 户 名：<input type='text' name='username'/><span id="usermsg" style="color:red;"></span><br/>
			密　　码：<input type='password' name='password'/><span id="passmsg" style="color:red;"></span><br/>
			确认密码：<input type='password' name='repassword'/><br/>
			性　　别：<input type='radio' name='sex' value='1' class='radio'/>男
			      <input type='radio' name='sex' value='0' class='radio'/>女<br/>
			验 证 码：<input type='text' name='code'/>
					  <img src='__APP__/Public/code?w=30&h=30' onclick='this.src=this.src+"?"+Math.random()'/><span id="codemsg" style="color:red;"></span>	  
				      <br/>
			<img src='__PUBLIC__/Images/register.gif' class='register'/>
			<img src='__PUBLIC__/Images/reset.gif' class='reset'/>
		</form>
	</body>
</html>